<?php

$prQuery = '';
$row = 0;

while (($data = fgetcsv($handle, 2048, ';')) !== FALSE) {
    $row++;

    ##CorrFormat Settings

    $CoReference = $data[0];
    $ReceiptFlag = $data[2];
    $ReceiptDate = substr($data[1], 0, 4) . '-' . substr($data[1], 4, 2) . '-' . substr($data[1], 6, 2);
    $ReceiptNotes = $data[3];

    ###

    if ($ReceiptFlag == 'P') {
        $prQuery .= "CALL transact_receivereceipt($CoReference,{$GETCOMMETH[$i]['CorrNumero']},'$ReceiptDate','$ReceiptNotes',@ResultCode); SELECT @ResultCode;";
    }
}
    $row = tuga_multiquery($prQuery);
    $ReturnCode = $row[0][0];